package me.zhengjie.minbearwcs.dao.common.impl;

import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
import lombok.RequiredArgsConstructor;
import me.zhengjie.minbearwcs.dao.common.inf.CommonTaskRecordDao;
import me.zhengjie.minbearwcs.entity.Mapper.common.CommonTaskRecordMapper;
import me.zhengjie.minbearwcs.entity.PO.wcs.common.CommonTaskRecord;
import org.springframework.stereotype.Repository;

@Repository
@RequiredArgsConstructor
public class CommonTaskRecordDaoImpl implements CommonTaskRecordDao {

    private final CommonTaskRecordMapper mapper;

    @Override
    public boolean insert(CommonTaskRecord commonTaskRecord) {
        return mapper.insert(commonTaskRecord) == 1;
    }

    @Override
    public CommonTaskRecord selectByRecordId(String recordId) {
        return new LambdaQueryChainWrapper<>(mapper)
                .eq(CommonTaskRecord::getCommonTaskRecordId, recordId)
                .oneOpt()
                .orElse(null);
    }
}
